<template>
  <div :class="{polCheck:true, polUnCheckedDisabled: polUnCheckedDisabled}">
    <div class="polCheckTitle">
      <span class="polName" v-if="pid !== 'P0007'">{{polName}}</span>
      <span class="polName" v-if="pid === 'P0007' && expiration === 'all'">鼎康保终身重大疾病保险</span>
      <span class="polName" v-else-if="pid === 'P0007' && expiration.indexOf('B') < 0">鼎康保定期重疾A款</span>
      <span class="polName" v-else-if="pid === 'P0007' && expiration.indexOf('B') > 0">鼎康保定期重疾B款</span>
      <i class="polCheckRadio iconfont" :class="{disabled: polCheckedDisable, checked: radioChecked}" @click="showCalContent"></i>
    </div>
    <div class="calContent" v-show="radioChecked" v-if="showPicker">
      <div class="calContentList" v-if="showInsuredDur">
        <span>保险期间</span>
        <jean-picker :jeanPickerDisabled="true"></jean-picker>
      </div>
      <div class="calContentList" v-if="pid==='P0007'">
        <span>满期方式</span>
        <jean-picker :jeanPickerData="expirationData" :jeanPickerDefaultValue="expirationValue" v-on:getJeanPicker="getExpiration" :changeShowData="expirationObj"></jean-picker>
      </div>
      <div class="calContentList">
        <span>{{calculateType === 'shortTerm' ? '保险期间' : '交费期间'}}</span>
        <!--<span>保险期间</span>-->
        <jean-picker :jeanPickerData="jeanPickerData" :jeanPickerDefaultValue="defaultValue" v-on:getJeanPicker="setPaymentperiod" :jeanPickerDisabled="(pid === 'P0007') ? false : true"></jean-picker>
      </div>
      <div class="calContentList" v-if="notInputPremium.indexOf(pid) < 0 && (calculateType !== 'exemption' && pid !== 'P0012')">
        <span>保额</span>
        <jean-input v-if="pid !== 'P0017'&&pid !== 'P0009'" :type="'number'" :jeanInputDefaultValue="premium" :jeanInputPlaceHolder="'请输入保额'" v-on:setInput="setPremium"></jean-input>
        <jean-input v-else-if="pid === 'P0017'" :type="'number'" :jeanInputDefaultValue="premium" :jeanInputPlaceHolder="'请输入保额'" v-on:setInput="setPremium" :maxNum="changePremium"></jean-input>
        <jean-input v-else-if="pid === 'P0009'" :type="'number'" :jeanInputDefaultValue="premium" :jeanInputPlaceHolder="'请输入保额'" v-on:setInput="setPremium" :maxNum="parseInt(changePremium * 5)"></jean-input>
      </div>
      <div class="calContentList" v-if="pid==='P0012'">
        <span>每日津贴</span>
        <div class="dailyAllowance">{{dailyAllowance}}元</div>
      </div>
      <div class="calContentList" v-if="pid==='P0012'">
        <span>份数</span>
        <jean-picker :jeanPickerData="countsData" :jeanPickerDefaultValue="countsVal" v-on:getJeanPicker="getCounts"></jean-picker>
      </div>
      <div class="calContentList" v-if="pid === 'P0013' || pid === 'P0014'">
        <span>保障计划</span>
        <jean-picker :jeanPickerData="guaranteeTypeData" :jeanPickerDefaultValue="guaranteeTypeVal" v-on:getJeanPicker="getGuaranteeType"></jean-picker>
      </div>
      <div class="calContentList"  v-if="pid === 'P0011' || pid === 'P0015'">
        <span>年给付限额</span>
        <jean-picker :jeanPickerData="quotaData" :jeanPickerDefaultValue="quotaVal" v-on:getJeanPicker="getQuotaType"></jean-picker>
      </div>
      <!--<div class="calContentList" v-if="notInputPremium.indexOf(pid) >= 0">-->
        <!--<span>保额</span>-->
        <!--<div class="countsPremium">{{countsPremium}}</div>-->
      <!--</div>-->
      <div class="calContentList" v-if="pid==='P0010'">
        <span>交通工具</span>
        <jean-picker :jeanPickerData="transportData" :jeanPickerDefaultValue="transportVal" v-on:getJeanPicker="getTransport" :addBtn="true"></jean-picker>
        <i class="iconfont icon-add_circle addBtn" @click="addTransport"></i>
        <!--<div class="transportList">-->
          <!--<span :class="{selected: selectTrain}" @click="selectTransport('train', 'selectTrain')">列车</span>-->
          <!--<span :class="{selected: selectShip}" @click="selectTransport('ship', 'selectShip')">轮船</span>-->
          <!--<span :class="{selected: selectCar}" @click="selectTransport('car', 'selectCar')">汽车</span>-->
          <!--<span :class="{selected: selectAirPlane}" @click="selectTransport('airplane', 'selectAirPlane')">民航班机</span>-->
        <!--</div>-->
      </div>
      <div class="calContentList" v-if="pid==='P0010'" v-for="(item, index) in transportListData" :key="index">
        <span>{{index === 0 ? '已选交通工具' : ''}}</span>
        <div class="transportList">{{`${item.name}/${item.premium}`}}</div>
        <i class="iconfont icon-delete_rubbish delBtn" @click="deleteTransport(index)"></i>
      </div>
    </div>
  </div>
</template>

<script>
import JeanPicker from './jeanPicker'
import JeanInput from './jeanInput'
import { Toast } from 'mint-ui'
export default {
  name: 'polCheck',
  props: ['changePremium', 'checkDisabled', 'checked', 'polName', 'showPicker', 'showInsuredDur', 'insureDurData', 'insureDurDefaultData', 'periodList', 'polIndex', 'pid', 'transportList', 'premium', 'paymentPeriod', 'calculateType', 'guaranteeType', 'quota', 'counts', 'expiration'],
  components: {JeanPicker, JeanInput},
  data () {
    return {
      polUnCheckedDisabled: false,
      polCheckedDisable: false,
      radioChecked: false,
      jeanPickerData: [],
      defaultValue: '',
      dailyAllowance: 0,
      paymentPeriodObj: {
        'pOne': '1年交',
        'pf': '5年交',
        'pt': '10年交',
        'pfif': '15年交',
        'pytw': '20年交',
        'pfo': '4年交',
        'pn': '9年交',
        'pfot': '14年交',
        'pnt': '19年交',
        'ptnt': '29年交',
        'ptt': '30年交',
        'pw': '趸交'
      },
      paymentPeriodObjShort: {
        'pf': '5年',
        'pt': '10年',
        'pfif': '15年',
        'pytw': '20年',
        'pOne': '1年',
        'pfo': '4年',
        'pn': '9年',
        'pfot': '14年',
        'pnt': '19年',
        'ptnt': '29年',
        'ptt': '30年'
      },
      paymentNumObj: {
        'pOne': 1,
        'pf': 5,
        'pt': 10,
        'pfif': 15,
        'pytw': 20,
        'ptt': 30,
        'pfo': 4,
        'pn': 9,
        'pfot': 14,
        'pnt': 19,
        'pw': 0
      },
      paymentPeriodPicker: '',
      countsData: [],
      countsVal: 0,
      countsPremium: 0,
      guaranteeTypeData: [],
      guaranteeTypeVal: '',
      guaranteeTypeNum: 0,
      quotaData: [],
      quotaVal: 0,
      quotaNum: 0,
      selectTrain: false,
      selectShip: false,
      selectCar: false,
      selectAirPlane: false,
      notInputPremium: ['P0011', 'P0013', 'P0014', 'P0015'],
      expirationData: [],
      expirationValue: '',
      expirationObj: {
        'all': '终身',
        'age70': '岁满期70岁',
        'age80': '岁满期80岁',
        'date30': '年满期30年',
        'date20': '年满期20年',
        'dateB10': '年满期10年',
        'dateB15': '年满期15年',
        'dateB20': '年满期20年',
        'dateB30': '年满期30年'
      },
      jeanPickerSpliceData: [],
      transportData: [
        {
          value: 'car',
          key: '汽车'
        },
        {
          value: 'train',
          key: '列车'
        },
        {
          value: 'airplane',
          key: '民航班机'
        },
        {
          value: 'ship',
          key: '轮船'
        }],
      transportListData: [],
      transportObj: {
        'car': '汽车',
        'train': '列车',
        'airplane': '民航班机',
        'ship': '轮船'
      },
      transportVal: 'car',
      transportMaxPremium: {
        'car': 1000000,
        'train': 1500000,
        'airplane': 3000000,
        'ship': 1000000
      },
      transportMinPremium: 50000,
      premiumVal: 0
    }
  },
  created: function () {
    // let cAge = Number(sessionStorage.getItem('cAge'))
    // let paymentPeriodJSON
    // if (this.calculateType === 'shortTerm') {
    //   paymentPeriodJSON = this.paymentPeriodObjShort
    // } else {
    //   paymentPeriodJSON = this.paymentPeriodObj
    // }
    // paymentPeriodJSON = this.paymentPeriodObjShort
    // if (this.pid === 'P0007') {
    //   let expiration = this.expiration
    //   for (let item of this.periodList) {
    //     if (expiration === 'all') {
    //       if (cAge <= 50) {
    //         this.jeanPickerData.push({
    //           key: paymentPeriodJSON[item],
    //           value: item
    //         })
    //       } else if (cAge > 50 && cAge <= 55) {
    //         if (item !== 'pfif' && item !== 'pytw') {
    //           this.jeanPickerData.push({
    //             key: paymentPeriodJSON[item],
    //             value: item
    //           })
    //         }
    //       } else if (cAge >= 55 && cAge <= 60) {
    //         if (item !== 'pfif' && item !== 'pytw' && item !== 'pt') {
    //           this.jeanPickerData.push({
    //             key: paymentPeriodJSON[item],
    //             value: item
    //           })
    //         }
    //       }
    //     } else if (expiration === 'date20') {
    //       if (cAge <= 40) {
    //         if (item !== 'pfif' && item !== 'pytw') {
    //           this.jeanPickerData.push({
    //             key: paymentPeriodJSON[item],
    //             value: item
    //           })
    //         } else {
    //           this.jeanPickerSpliceData.push({
    //             key: paymentPeriodJSON[item],
    //             value: item
    //           })
    //         }
    //       } else if (cAge > 40 && cAge <= 45) {
    //         if (item !== 'pfif' && item !== 'pytw') {
    //           this.jeanPickerData.push({
    //             key: paymentPeriodJSON[item],
    //             value: item
    //           })
    //         } else if (item === 'pfif') {
    //           this.jeanPickerSpliceData.push({
    //             key: paymentPeriodJSON[item],
    //             value: item
    //           })
    //         }
    //       } else if (cAge > 45 && cAge <= 50) {
    //         if (item === 'pt' || item === 'pf' || item === 'pw') {
    //           this.jeanPickerData.push({
    //             key: paymentPeriodJSON[item],
    //             value: item
    //           })
    //         }
    //       } else if (cAge > 50 && cAge <= 55) {
    //         if (item === 'pf' || item === 'pw') {
    //           this.jeanPickerData.push({
    //             key: paymentPeriodJSON[item],
    //             value: item
    //           })
    //         }
    //       } else if (cAge > 55 && cAge <= 60) {
    //         if (item === 'pw') {
    //           this.jeanPickerData.push({
    //             key: paymentPeriodJSON[item],
    //             value: item
    //           })
    //         }
    //       }
    //     } else {
    //       if (cAge <= 40) {
    //         this.jeanPickerData.push({
    //           key: paymentPeriodJSON[item],
    //           value: item
    //         })
    //       } else if (cAge > 40 && cAge <= 45) {
    //         if (item !== 'pytw') {
    //           this.jeanPickerData.push({
    //             key: paymentPeriodJSON[item],
    //             value: item
    //           })
    //         }
    //       } else if (cAge > 45 && cAge <= 50) {
    //         if (item === 'pt' || item === 'pf' || item === 'pw') {
    //           this.jeanPickerData.push({
    //             key: paymentPeriodJSON[item],
    //             value: item
    //           })
    //         }
    //       } else if (cAge > 50 && cAge <= 55) {
    //         if (item === 'pf' || item === 'pw') {
    //           this.jeanPickerData.push({
    //             key: paymentPeriodJSON[item],
    //             value: item
    //           })
    //         }
    //       } else if (cAge > 55 && cAge <= 60) {
    //         if (item === 'pw') {
    //           this.jeanPickerData.push({
    //             key: paymentPeriodJSON[item],
    //             value: item
    //           })
    //         }
    //       }
    //     }
    //   }
    // }
    this.defaultValue = this.paymentPeriod
    this.paymentPeriodPicker = this.paymentPeriod
    this.premiumVal = this.premium
    this.transportListData = this.transportList
    if (this.pid === 'P0012') {
      this.countsVal = this.counts
      this.dailyAllowance = this.counts * 10
      this.countsData = [{
        value: this.countsVal,
        key: `${this.countsVal}份`
      }]
    }
    if (this.pid === 'P0007') {
      let cAge = sessionStorage.getItem('cAge')
      if (cAge > 60) {
        this.expirationData = [
          {
            key: '鼎康保定期重疾B款-年满期10年',
            value: 'dateB10'
          }
        ]
      } else if (cAge > 55 && cAge <= 60) {
        this.expirationData = [
          {
            key: '鼎康保终身重大疾病保险',
            value: 'all'
          },
          {
            key: '鼎康保定期重疾A款-岁满期70岁',
            value: 'age70'
          },
          {
            key: '鼎康保定期重疾A款-岁满期80岁',
            value: 'age80'
          },
          {
            key: '鼎康保定期重疾A款-年满期30年',
            value: 'date30'
          },
          {
            key: '鼎康保定期重疾A款-年满期20年',
            value: 'date20'
          },
          {
            key: '鼎康保定期重疾B款-年满期10年',
            value: 'dateB10'
          },
          {
            key: '鼎康保定期重疾B款-年满期15年',
            value: 'dateB15'
          }
        ]
      } else if (cAge > 45 && cAge <= 55) {
        this.expirationData = [
          {
            key: '鼎康保终身重大疾病保险',
            value: 'all'
          },
          {
            key: '鼎康保定期重疾A款-岁满期70岁',
            value: 'age70'
          },
          {
            key: '鼎康保定期重疾A款-岁满期80岁',
            value: 'age80'
          },
          {
            key: '鼎康保定期重疾A款-年满期30年',
            value: 'date30'
          },
          {
            key: '鼎康保定期重疾A款-年满期20年',
            value: 'date20'
          },
          {
            key: '鼎康保定期重疾B款-年满期10年',
            value: 'dateB10'
          },
          {
            key: '鼎康保定期重疾B款-年满期15年',
            value: 'dateB15'
          },
          {
            key: '鼎康保定期重疾B款-年满期20年',
            value: 'dateB20'
          }
        ]
      } else {
        this.expirationData = [
          {
            key: '鼎康保终身重大疾病保险',
            value: 'all'
          },
          {
            key: '鼎康保定期重疾A款-岁满期70岁',
            value: 'age70'
          },
          {
            key: '鼎康保定期重疾A款-岁满期80岁',
            value: 'age80'
          },
          {
            key: '鼎康保定期重疾A款-年满期30年',
            value: 'date30'
          },
          {
            key: '鼎康保定期重疾A款-年满期20年',
            value: 'date20'
          },
          {
            key: '鼎康保定期重疾B款-年满期10年',
            value: 'dateB10'
          },
          {
            key: '鼎康保定期重疾B款-年满期15年',
            value: 'dateB15'
          },
          {
            key: '鼎康保定期重疾B款-年满期20年',
            value: 'dateB20'
          },
          {
            key: '鼎康保定期重疾B款-年满期30年',
            value: 'dateB30'
          }
        ]
      }
      this.expirationValue = this.expiration
    }
    if (this.pid === 'P0013' || this.pid === 'P0014') {
      this.guaranteeTypeData = [
        {
          value: '1',
          key: '计划一'
        },
        {
          value: '2',
          key: '计划二'
        },
        {
          value: '3',
          key: '计划三'
        }
      ]
      if (this.guaranteeType === '1') {
        this.guaranteeTypeNum = 90400
      }
      if (this.guaranteeType === '2') {
        this.guaranteeTypeNum = 177200
      }
      if (this.guaranteeType === '3') {
        this.guaranteeTypeNum = 349000
      }
      this.guaranteeTypeVal = this.guaranteeType
      this.countsPremium = this.guaranteeTypeNum * this.paymentNumObj[this.defaultValue]
    }
    if (this.pid === 'P0011' || this.pid === 'P0015') {
      this.quotaData = [
        {
          value: 5000,
          key: '5000元'
        },
        {
          value: 10000,
          key: '10000元'
        },
        {
          value: 20000,
          key: '20000元'
        },
        {
          value: 30000,
          key: '30000元'
        },
        {
          value: 50000,
          key: '50000元'
        }
      ]
      this.quotaVal = this.quota
      this.quotaNum = this.quota
      this.countsPremium = this.quota * this.paymentNumObj[this.defaultValue]
    }
    this.getPeriodList()
  },
  mounted: function () {
    this.radioChecked = this.checked
    if (this.checkDisabled === 'checkDisabled') {
      this.polCheckedDisable = true
      this.polUnCheckedDisabled = false
      this.radioChecked = true
    } else if (this.checkDisabled === 'unCheckDisabled') {
      this.polCheckedDisable = false
      this.polUnCheckedDisabled = true
      this.radioChecked = false
    } else {
      this.polCheckedDisable = false
      this.polUnCheckedDisabled = false
    }
    if (this.transportList) {
      for (let item of this.transportList) {
        if (item === 'car') {
          this.selectCar = true
        } else if (item === 'ship') {
          this.selectShip = true
        } else if (item === 'train') {
          this.selectTrain = true
        } else if (item === 'airplane') {
          this.selectAirPlane = true
        }
      }
    }
  },
  methods: {
    getPeriodList () {
      let expiration = this.expirationValue
      let cAge = Number(sessionStorage.getItem('cAge'))
      let paymentPeriodJSON
      if (this.calculateType === 'shortTerm') {
        paymentPeriodJSON = this.paymentPeriodObjShort
      } else {
        paymentPeriodJSON = this.paymentPeriodObj
      }
      this.jeanPickerData = []
      if (sessionStorage.getItem('cAge') > 60) {
        if (this.pid === 'P0007') {
          this.jeanPickerData = [
            {
              key: '10年交',
              value: 'pt'
            }]
        } else if (this.pid === 'P0008') {
          this.jeanPickerData = [
            {
              key: '9年交',
              value: 'pn'
            }]
        } else if (this.pid === 'P0017') {
          this.jeanPickerData = [
            {
              key: '1年交',
              value: 'pOne'
            }]
        }
      } else {
        for (let item of this.periodList) {
          if (expiration === 'all') {
            if (cAge <= 50) {
              this.jeanPickerData.push({
                key: paymentPeriodJSON[item],
                value: item
              })
            } else if (cAge > 50 && cAge <= 55) {
              if (item !== 'pfif' && item !== 'pytw') {
                this.jeanPickerData.push({
                  key: paymentPeriodJSON[item],
                  value: item
                })
              }
            } else if (cAge >= 55 && cAge <= 60) {
              if (item !== 'pfif' && item !== 'pytw' && item !== 'pt') {
                this.jeanPickerData.push({
                  key: paymentPeriodJSON[item],
                  value: item
                })
              }
            }
          } else if (expiration === 'date20' || expiration === 'date30' || expiration === 'age70' || expiration === 'age80' || !expiration) {
            if (cAge <= 40) {
              this.jeanPickerData.push({
                key: paymentPeriodJSON[item],
                value: item
              })
            } else if (cAge > 40 && cAge <= 45) {
              if (item !== 'pytw') {
                this.jeanPickerData.push({
                  key: paymentPeriodJSON[item],
                  value: item
                })
              }
            } else if (cAge > 45 && cAge <= 50) {
              if (item !== 'pfif' && item !== 'pytw') {
                this.jeanPickerData.push({
                  key: paymentPeriodJSON[item],
                  value: item
                })
              }
            } else if (cAge > 50 && cAge <= 55) {
              if (item !== 'pfif' && item !== 'pytw' && item !== 'pt') {
                this.jeanPickerData.push({
                  key: paymentPeriodJSON[item],
                  value: item
                })
              }
            } else if (cAge > 55 && cAge <= 60) {
              if (item !== 'pfif' && item !== 'pytw' && item !== 'pt' && item !== 'pf') {
                this.jeanPickerData.push({
                  key: paymentPeriodJSON[item],
                  value: item
                })
              }
            }
          }
        }
        if (expiration === 'dateB10') {
          this.jeanPickerData = [{
            key: '10年交',
            value: 'pt'
          }]
        } else if (expiration === 'dateB15') {
          this.jeanPickerData = [
            {
              key: '10年交',
              value: 'pt'
            },
            {
              key: '15年交',
              value: 'pfif'
            }
          ]
        } else if (expiration === 'dateB20') {
          if (cAge <= 55) {
            this.jeanPickerData = [
              {
                key: '10年交',
                value: 'pt'
              },
              {
                key: '15年交',
                value: 'pfif'
              },
              {
                key: '20年交',
                value: 'pytw'
              }
            ]
          } else if (cAge > 55) {
            this.jeanPickerData = [
              {
                key: '10年交',
                value: 'pt'
              },
              {
                key: '15年交',
                value: 'pfif'
              }
            ]
          }
        } else if (expiration === 'dateB30') {
          if (cAge <= 45) {
            this.jeanPickerData = [
              {
                key: '10年交',
                value: 'pt'
              },
              {
                key: '15年交',
                value: 'pfif'
              },
              {
                key: '20年交',
                value: 'pytw'
              },
              {
                key: '30年交',
                value: 'ptt'
              }
            ]
          } else if (cAge > 45 && cAge <= 55) {
            this.jeanPickerData = [
              {
                key: '10年交',
                value: 'pt'
              },
              {
                key: '15年交',
                value: 'pfif'
              },
              {
                key: '20年交',
                value: 'pytw'
              }
            ]
          } else if (cAge > 55) {
            this.jeanPickerData = [
              {
                key: '10年交',
                value: 'pt'
              },
              {
                key: '15年交',
                value: 'pfif'
              }
            ]
          }
        }
      }
    },
    showCalContent () {
      if (!this.checkDisabled) {
        this.radioChecked = !this.radioChecked
        if (this.pid === 'P0010' && this.radioChecked) {
          this.selectCar = true
          this.selectShip = true
          this.selectTrain = true
          this.selectAirPlane = true
          this.$emit('setData', 'transportList', this.pid, ['car', 'ship', 'train', 'airplane'])
        }
        this.$emit('getCheckStatus', this.radioChecked, this.polIndex, this.pid)
      }
    },
    setPaymentperiod (data) {
      this.paymentPeriodPicker = data
      this.$emit('setData', 'paymentPeriod', this.pid, data)
      this.$emit('setData', 'expiration', this.pid, this.expirationValue)
    },
    getCounts (data) {
      this.countsVal = data
      this.dailyAllowance = data * 10
      this.$emit('setData', 'counts', this.pid, data)
    },
    setPremium (data) {
      this.premiumVal = data
      if (Number(this.premiumVal) > Number(this.changePremium) && this.pid === 'P0017') {
        this.premiumVal = this.changePremium
        this.$emit('setData', 'premium', this.pid, this.premiumVal)
      } else if (Number(this.premiumVal) > (Number(this.changePremium) * 5) && this.pid === 'P0009') {
        this.premiumVal = this.changePremium / 5
        this.$emit('setData', 'premium', this.pid, this.premiumVal)
      } else {
        this.$emit('setData', 'premium', this.pid, data)
      }
    },
    selectTransport (type, selected) {
      let transportList = this.transportList
      this[selected] = !this[selected]
      if (!this[selected]) {
        for (let i = 0; i < transportList.length; i++) {
          if (transportList[i] === type) {
            transportList.splice(i, 1)
          }
        }
      } else {
        transportList.push(type)
      }
      if (transportList.length) {
        this.$emit('setData', 'transportList', this.pid, transportList)
      } else {
        this.radioChecked = false
        this.$emit('getCheckStatus', this.radioChecked, this.polIndex)
      }
    },
    getGuaranteeType (data) {
      let num
      if (data === '1') {
        num = 90400
      }
      if (data === '2') {
        num = 177200
      }
      if (data === '3') {
        num = 349000
      }
      this.guaranteeTypeNum = num
      this.countsPremium = num * this.paymentNumObj[this.paymentPeriodPicker]
      this.$emit('setData', 'guaranteeType', this.pid, data)
      this.$emit('setData', 'premium', this.pid, this.countsPremium)
    },
    getQuotaType (data) {
      this.quotaNum = data
      this.countsPremium = data * this.paymentNumObj[this.paymentPeriodPicker]
      this.$emit('setData', 'quota', this.pid, data)
      this.$emit('setData', 'premium', this.pid, this.countsPremium)
    },
    getExpiration (data) {
      this.$emit('setData', 'expiration', this.pid, data)
      this.expirationValue = data
      // if (data === 'date20') {
      //   let periodList = JSON.parse(JSON.stringify(this.jeanPickerData))
      //   let spliceNum = 0
      //   for (let i = 0; i < this.jeanPickerData.length; i++) {
      //     if (this.jeanPickerData[i].value === 'pfif' || this.jeanPickerData[i].value === 'pytw') {
      //       this.jeanPickerSpliceData.push(this.jeanPickerData[i])
      //       periodList.splice(i - spliceNum, 1)
      //       spliceNum++
      //     }
      //   }
      //   this.jeanPickerData = periodList
      //   if (this.defaultValue === 'pfif' || this.defaultValue === 'pytw') {
      //     this.defaultValue = 'pt'
      //   }
      // } else {
      //   for (let item of this.jeanPickerSpliceData) {
      //     this.$set(this.jeanPickerData, this.jeanPickerData.length, item)
      //   }
      //   this.jeanPickerSpliceData = []
      // }
      this.getPeriodList()
      if (this.paymentNumObj[this.defaultValue] > this.paymentNumObj[this.jeanPickerData[this.jeanPickerData.length - 1].value] || this.defaultValue === 'pw') {
        this.defaultValue = this.jeanPickerData[this.jeanPickerData.length - 1].value
        this.$emit('setData', 'paymentPeriod', this.pid, this.defaultValue)
      }
      if (this.pid === 'P0007' && data === 'all') {
        this.$emit('setData', 'pname', this.pid, '鼎康保终身重大疾病保险')
      } else if (this.pid === 'P0007' && (data === 'date70' || data === 'date80' || data === 'age20' || data === 'age30')) {
        this.$emit('setData', 'pname', this.pid, '鼎康保定期重疾A款')
      } else {
        this.$emit('setData', 'pname', this.pid, '鼎康保定期重疾B款')
      }
    },
    getTransport (data) {
      this.transportVal = data
    },
    addTransport () {
      let has = false
      for (let item of this.transportListData) {
        if (item.val === this.transportVal) {
          has = true
        }
      }
      if (has) {
        Toast('该交通工具已选择')
      } else {
        if (this.premiumVal) {
          if (Number(this.premiumVal) <= this.transportMaxPremium[this.transportVal] && Number(this.premiumVal) >= this.transportMinPremium) {
            this.transportListData.push({
              name: this.transportObj[this.transportVal],
              val: this.transportVal,
              premium: this.premiumVal
            })
            this.$emit('setData', 'transportListData', this.pid, this.transportListData)
          } else if (Number(this.premiumVal) > this.transportMaxPremium[this.transportVal]) {
            Toast(this.transportObj[this.transportVal] + '的最高保额为' + this.transportMaxPremium[this.transportVal])
          } else if (Number(this.premiumVal) < this.transportMinPremium) {
            Toast(this.transportObj[this.transportVal] + '的最低保额为' + this.transportMinPremium)
          }
        } else {
          Toast('请填写保额')
        }
      }
    },
    deleteTransport (index) {
      this.transportListData.splice(index, 1)
      this.$emit('setData', 'transportListData', this.pid, this.transportListData)
    }
  },
  watch: {
    paymentPeriod (val) {
      this.defaultValue = val
      this.paymentPeriodPicker = val
      // if (this.pid === 'P0012') {
      //   this.countsPremium = this.countsVal * this.paymentNumObj[val] * 2400
      //   this.$emit('setData', 'premium', this.pid, this.countsPremium)
      // }
      if (this.pid === 'P0013' || this.pid === 'P0014') {
        this.countsPremium = this.guaranteeTypeNum * this.paymentNumObj[val]
        this.$emit('setData', 'premium', this.pid, this.countsPremium)
      }
      if (this.pid === 'P0011' || this.pid === 'P0015') {
        this.countsPremium = this.quotaNum * this.paymentNumObj[val]
        this.$emit('setData', 'premium', this.pid, this.countsPremium)
      }
    },
    checked (val) {
      this.radioChecked = val
    },
    checkDisabled (val) {
      if (val === 'checkDisabled') {
        this.polCheckedDisable = true
        this.polUnCheckedDisabled = false
        this.radioChecked = true
      } else if (val === 'unCheckDisabled') {
        this.polCheckedDisable = false
        this.polUnCheckedDisabled = true
        this.radioChecked = false
      } else {
        this.polCheckedDisable = false
        this.polUnCheckedDisabled = false
      }
    },
    changePremium (val) {
      if ((this.pid === 'P0011' || this.pid === 'P0015' || this.pid === 'P0012') && val >= 50000) {
        // 设置意外医疗费用补偿与主险关系
        let premiumArray = [5000, 10000, 20000, 30000, 50000]
        let premiumArray2 = []
        let premium = val / 5
        this.quotaData = []
        for (let item of premiumArray) {
          if (premium >= item) {
            premiumArray2.push({
              value: item,
              key: `${item}元`
            })
          }
        }
        this.quotaData = premiumArray2
        let hasQuotaNum = false
        for (let item of premiumArray2) {
          if (item.value === this.quotaNum) {
            hasQuotaNum = true
            break
          }
        }
        if (!hasQuotaNum) {
          this.quotaNum = premiumArray2[0].value
          this.countsPremium = this.quotaNum * this.paymentNumObj[this.paymentPeriodPicker]
          this.$emit('setData', 'quota', this.pid, this.quotaNum)
          this.$emit('setData', 'premium', this.pid, this.countsPremium)
        }
        // 设置意外伤害定额与主险关系
        let maxCounts = parseInt(val / 10000)
        if (this.pid === 'P0012') {
          this.countsData = []
          let hasCounts = false
          let countsData = []
          for (let i = 4; i < maxCounts; i++) {
            countsData.push({
              value: i + 1,
              key: (i + 1) + '份'
            })
            if (i + 1 === this.countsVal) {
              hasCounts = true
            }
          }
          this.countsData = countsData
          if (!hasCounts) {
            this.countsVal = this.countsData[this.countsData.length - 1].value
            this.dailyAllowance = this.countsVal * 10
            this.$emit('setData', 'counts', this.pid, this.countsVal)
          }
        }
      }
    }
  }
}
</script>

<style scoped>
  .polCheck {
    padding: 15px 15px;
    border-bottom: 1px solid #dfdfdf;
  }
  .polCheck:last-of-type {
    border-bottom: none;
  }
  .polCheckTitle {
    width: 100%;
    position: relative;
    overflow: hidden;
    white-space: nowrap;
    padding: 2px 0;
    text-overflow: ellipsis;
  }
  .polCode {
    padding: 2px 4px;
    border: 1px solid #ff5700;
    color: #ff5700;
    border-radius: 4px;
    font-size: 16px;
  }
  .polName {
    font-size: 18px;
    padding-left: 5px;
  }
  .polUnCheckedDisabled .polName {
    color: #bebebe;
  }
  .polCheckRadio {
    position: absolute;
    display: block;
    right: 0;
    top: 4px;
    text-align: center;
    line-height: 20px;
    font-size: 20px;
    color: #113dff;
  }
  .polCheckRadio:before {
    content: "\e651";
  }
  .polCheckRadio.checked:before {
    content: "\e629";
  }
  .checked {
    color: #113dff;
  }
  .polCheckRadio.disabled {
    color: #99ceff;
  }
  .polUnCheckedDisabled .polCheckRadio {
    color: #99ceff;
  }
  .calContent {
    width: 100%;
    position: relative;
  }
  .calContentList {
    width: 100%;
    position: relative;
    padding: 5px 0;
    margin-top: 10px;
  }
  .calContentList>span {
    padding-left: 5px;
  }
  .countsPremium {
    width: 130px;
    height: 25px;
    border: 1px solid #c9c9c9;
    text-align: left;
    line-height: 25px;
    position: absolute;
    right: 0;
    top: 2px;
    padding: 0 5px;
    font-size: 13px;
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
  }
  .dailyAllowance {
    width: 140px;
    height: 25px;
    border: 1px solid #c9c9c9;
    text-align: left;
    line-height: 25px;
    position: absolute;
    right: 0;
    top: 2px;
    padding: 0 5px;
    font-size: 13px;
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
  }
  .transportList {
    width: 110px;
    height: 25px;
    border: 1px solid #c9c9c9;
    text-align: left;
    line-height: 25px;
    position: absolute;
    right: 30px;
    top: 2px;
    padding: 0 5px;
    font-size: 13px;
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
  }
  .transportList>span {
    padding: 5px 5px;
    float: left;
    border: 1px solid #c9c9c9;
    color: #000000;
    margin-left: 5px;
    margin-top: 2px;
    border-radius: 3px;
  }
  .transportList>span.selected {
    border: 1px solid #113dff;
    color: #113dff;
  }
  .addBtn {
    width: 25px;
    height: 25px;
    position: absolute;
    right: 0;
    top: 2px;
    font-size: 25px;
  }
  .delBtn {
    width: 25px;
    height: 25px;
    position: absolute;
    right: 0;
    top: 2px;
    font-size: 25px;
  }
</style>
